<?php
//no direct access
defined('_JEXEC') or die( 'Restricted access' );
//import the JController Class
jimport( 'joomla.application.component.model' );

class NvModelSearch extends JModel{
	
	function searchObject($keyword){
		
				
		
		//lowered case the keyword
		$keylowered = strtolower($keyword);
		
		//set SQL query
		$db =& JFactory::getDBO();
		//prepare the query
		 $query = "select name,nama_kota,latitude,longitude,keterangan from #__nusaview as jnv
					LEFT JOIN #__kota as jk using(kota_id,propinsi_id) where name like \"%".$keylowered."%\"";
	
		//do query on database	
		$db->setQuery($query);
		
		
		if(!$db->query()){
			
			echo $db->getErrorMsg();
		}
		
		$rows = $db->loadObjectList();
		
		
		//data array for storing tourism object
		$data = array();
		$index = 0;
		
		foreach ($rows as $row){
			
			$data[$index++] = $row;
			
			
		}
		
		
		return $data;
		
						
	}
}

?>